package dev.bong.mapper;


import dev.bong.annotation.AutoFill;
import dev.bong.enumeration.OperationType;
import dev.bong.pojo.entity.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoleMapper {


    @Select("select * from role")
    List<Role> getAllRole();

    @Select("select *from role where id = #{id}")
    Role getRoleById(Integer id);
    @Select("select *from role where role_name = #{name}")
    Role getRoleByName(String name);


    @AutoFill(OperationType.INSERT)
    @Insert("insert into role (role_name,create_by,create_time,update_by,update_time) " +
            "values(#{roleName},#{createBy},#{createTime},#{updateBy},#{updateTime})")
    void addRole(Role role);

    @AutoFill(OperationType.UPDATE)
    @Update("update role set role_name = #{roleName},update_by=#{updateBy},update_time=#{updateTime} " +
            "where id = #{id}")
    void updateRole(Role role);


    @Delete("delete from role where id = #{id}")
    void deleteRole(Integer id);

    @Delete("delete from role where id in (#{ids})")
    void deleteRoleByIds(@Param("ids") List<Integer> ids);



}
